
import numpy as np
import pyqtgraph as pg

win = pg.GraphicsLayoutWidget(show=True)
win.setWindowTitle('pyqtgraph example: Scrolling Plots')

p4 = win.addPlot()
p4.setDownsampling(mode='peak')
p4.setClipToView(True)
curve4 = p4.plot()
data3 = np.empty(100)
ptr3 = 0

def update2():
    global data3, ptr3
    data3[ptr3] = np.random.normal()
    ptr3 += 1
    if ptr3 >= data3.shape[0]:
        tmp = data3
        data3 = np.empty(data3.shape[0] * 2)
        data3[:tmp.shape[0]] = tmp
    curve4.setData(data3[:ptr3])

timer = pg.QtCore.QTimer()
timer.timeout.connect(update2)
timer.start(50)

if __name__ == '__main__':
    pg.exec()